package com.lite.haru.alarmpolice.activity;

import org.kymjs.kjframe.KJActivity;
import org.kymjs.kjframe.ui.BindView;

import com.lite.haru.R;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;

public class AlarmSettingAty extends KJActivity {

	private SharedPreferences sp;
	@BindView(id = R.id.personInfo, click = true)
	private TextView personInfo;
	@BindView(id = R.id.aboutInfo, click = true)
	private TextView aboutInfo;
	@BindView(id = R.id.logout, click = true)
	private TextView logout;
	@BindView(id = R.id.backHome, click = true)
	private TextView backHome;

	@Override
	public void setRootView() {
		setContentView(R.layout.aty_alarm_setting);
	}

	@Override
	public void initData() {

		super.initData();
	}

	@Override
	public void initWidget() {

		super.initWidget();
	}

	@Override
	public void widgetClick(View v) {
		super.widgetClick(v);

		switch (v.getId()) {
		case R.id.personInfo:
			Intent intent = new Intent();
			intent.setClass(getApplicationContext(), PoliceInfoAty.class);

			startActivity(intent);
			break;
		case R.id.aboutInfo:
			Intent intent1 = new Intent();
			intent1.setClass(getApplicationContext(), AboutAty.class);
			startActivity(intent1);
			break;

		case R.id.logout:
			showDialog_Layout(aty);
			break;

		case R.id.backHome:
			AlarmSettingAty.this.finish();
			break;

		default:
			break;
		}
	}

	public void showDialog_Layout(Context context) {

		LayoutInflater inflater = LayoutInflater.from(this);
		// 绑定 布局
		View view = inflater.inflate(R.layout.view_dialog, null);

		AlertDialog.Builder builder = new AlertDialog.Builder(context);

		builder.setCancelable(false);// 设置为false，按返回键不能退出。默认为true。

		builder.setView(view);
		builder.setPositiveButton("确认", new DialogInterface.OnClickListener() {
			public void onClick(DialogInterface dialog, int whichButton) {
				sp = getSharedPreferences("AlarmPoliceinfo",
						Activity.MODE_PRIVATE);
				SharedPreferences.Editor editor = sp.edit();
				editor.clear().commit();
				AlarmSettingAty.this.finish();
				Intent intent = new Intent(getApplicationContext(),
						PoliceLoginAty.class);
				// 此方法要求最低API为11
				intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
						| Intent.FLAG_ACTIVITY_CLEAR_TASK);
				startActivity(intent);
			}
		});
		builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
			public void onClick(DialogInterface dialog, int whichButton) {
				return;
			}
		});
		builder.show();
	}

}
